package com.hadoop.mr.amiudake.flow;

import java.io.IOException;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

public class FlowReduce extends Reducer<Text, FlowBean, Text, FlowBean>{
	
	@Override
	protected void reduce(Text key, Iterable<FlowBean> values, Reducer<Text, FlowBean, Text, FlowBean>.Context context)
			throws IOException, InterruptedException {
		try {
			long flowSum = 0L;
			System.out.println("!");
			FlowBean bean = new FlowBean();
			for (FlowBean fb : values) {
				bean.setArea(fb.getArea());
				bean.setName(bean.getName());
				bean.setPhone(fb.getPhone());
				flowSum = flowSum + fb.getFlow();
			}
			bean.setFlow(flowSum);
			context.write(key, bean);
		} catch (Exception e) {
			e.printStackTrace();
		}
		
	}

}
